import { createRouter, createWebHistory } from 'vue-router'
import HomePage from "@/pages/HomePage.vue";
import NoAuthPage from "@/pages/NoAuthPage.vue";
import UserLoginPage from "@/pages/user/UserLoginPage.vue";
import UserManagePage from "@/pages/admin/UserManagePage.vue";
import UserRegisterPage from "@/pages/user/UserRegisterPage.vue";
import AddPicturePage from "@/pages/AddPicturePage.vue"
import pictureManagePage from "@/pages/admin/PictureManagePage.vue";
import PictureDetailPage from "@/pages/PictureDetailPage.vue";
import AddPictureBatchPage from "@/pages/AddPictureBatchPage.vue";
import SpaceManagePage from "@/pages/admin/SpaceManagePage.vue";
import AddSpacePage from "@/pages/AddSpacePage.vue";
import MySpacePage from "@/pages/MySpacePage.vue";
import SpaceDetailPage from "@/pages/SpaceDetailPage.vue";
import SearchPicturePage from "@/pages/SearchPicturePage.vue";
import SpaceAnalyzePage from "@/pages/SpaceAnalyzePage.vue";
import SpaceUserManagePage from "@/pages/SpaceUserManagePage.vue";
import UserInfoPage from "@/pages/user/UserInfoPage.vue";

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: '主页',
      component: HomePage,
    },
    {
      path: '/user/login',
      name: '用户登录',
      component: UserLoginPage,
    },
    {
      path: '/user/register',
      name: '用户注册',
      component: UserRegisterPage,
    },
    {
      path: '/add_picture',
      name: '创建图片',
      component: AddPicturePage,
      meta: {
          requiresAuth: true
      }
    },
    {
      path: '/add_space',
      name: '创建空间',
      component: AddSpacePage,
      meta: {
          requiresAuth: true
      }
    },
    {
      path: '/add_picture/batch',
      name: '批量上传图片',
      component: AddPictureBatchPage,
      meta: {
          // 设置权限，只允许管理员
          requiresAdmin: true
      },
    },
    {
      path: '/search_picture',
      name: '以图搜图',
      component: SearchPicturePage,
      meta: {
          requiresAuth: true
      }
    },
    {
      path: '/picture/:id',
      name: '图片详情',
      component: PictureDetailPage,
      props: true,
    },
    {
      path: '/space/:id',
      name: '空间详情',
      component: SpaceDetailPage,
      props: true,
      meta: {
          requiresAuth: true
      }
    },
    {
      path: '/space_analyze',
      name: '空间分析',
      component: SpaceAnalyzePage,
      meta: {
          requiresAuth: true
      }
    },
    {
      path: '/admin/userManage',
      name: '用户管理',
      component: UserManagePage,
      meta: {
        // 设置权限，只允许管理员
          requiresAdmin: true
      },
    },
    {
      path: '/admin/pictureManage',
      name: '图片管理',
      component: pictureManagePage,
      meta: {
        // 设置权限，只允许管理员
        requiresAdmin: true
      },
    },
    {
      path: '/admin/spaceManage',
      name: '空间管理',
      component: SpaceManagePage,
      meta: {
        // 设置权限，只允许管理员
          requiresAdmin: true
      },
    },
    {
      path: '/spaceUserManage/:id',
      name: '空间成员管理',
      component: SpaceUserManagePage,
      props: true,
      meta: {
          requiresAuth: true
      }
    },
    {
      path: '/my_space',
      name: '我的空间',
      component: MySpacePage,
      meta: {
          requiresAuth: true
      }
    },
    {
      path: '/my_info',
      name: '个人信息',
      component: UserInfoPage,
      meta: {
        requiresAuth: true
      }
    },
    {
      path: '/noAuth',
      name: '无权限',
      component: NoAuthPage,
    },
  ],
})

export default router
